package com.link.base.base.common.controller;

import com.alibaba.fastjson.JSONObject;
import com.link.base.base.common.model.SendSms;
import com.link.base.base.common.service.SendSmsService;
import com.link.core.util.JsonUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author yipeng.zhu@hand-china.com
 * @version 1.0
 * @date: 11:33 2018/11/29
 */

@Controller
@RequestMapping("/link/sendsms")
public class SendSmsController {
    @Resource
    private SendSmsService sendSmsService;

    /**
     * post请求调用发送短信接口
     * @author yipeng.zhu@hand-china.com
     * @param sendSms
     * @return
     */
    @RequestMapping("/sendMsg")
    @ResponseBody
    public JSONObject sendSms(@RequestBody SendSms sendSms) {
        String  templateCode = sendSms.getTemplateCode();
        String  param = sendSms.getParams();
        String  phoneNumber = sendSms.getPhoneNumber();
        String result = sendSmsService.sendSms(templateCode,param,"",phoneNumber);
        return JsonUtil.toJsonObject(result);
    }
}
